package com.bangbang.blog.controller;


import com.bangbang.blog.pojo.TbIntegral;
import com.bangbang.blog.service.impl.TbIntegralServiceImpl;
import com.bangbang.configresult.Result;
import com.bangbang.configresult.ResultEnum;
import io.swagger.annotations.ApiImplicitParam;
import io.swagger.annotations.ApiImplicitParams;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import org.springframework.stereotype.Controller;

/**
 * <p>
 * 积分账号信息表 前端控制器
 * </p>
 *
 * @author ${author}
 * @since 2021-08-12
 */
@RestController
@RequestMapping("/blog/tbIntegral")
public class TbIntegralController {

    @Autowired
    private TbIntegralServiceImpl tbIntegralService;

    //新增
    @PostMapping
    @ApiOperation("积分添加方法")
    @ApiImplicitParams({
            @ApiImplicitParam(name = "tbIntegral",value = "积分实体类",required = true,paramType = "body")
    })
    public Result insert(@RequestBody TbIntegral tbIntegral){
        tbIntegralService.insert(tbIntegral);
        return Result.buildResult(ResultEnum.SUCCESS);
    }

    //修改
    @PutMapping
    @ApiOperation("积分修改方法")
    @ApiImplicitParams({
            @ApiImplicitParam(name = "tbIntegral",value = "积分实体类",required = true,paramType = "body")
    })
    public Result update(@RequestBody TbIntegral tbIntegral){
        tbIntegralService.updateById(tbIntegral);
        return Result.buildResult(ResultEnum.SUCCESS);
    }
    //删除
    @DeleteMapping
    @ApiOperation("积分删除方法")
    @ApiImplicitParams({
            @ApiImplicitParam(name = "ralId",value = "积分id",required = true,paramType = "query")
    })
    public Result delete(@RequestParam(required = true)Long ralId){
            tbIntegralService.delete(ralId);
            return Result.buildResult(ResultEnum.SUCCESS);
    }

    //查询
    @GetMapping
    @ApiOperation("积分查询")
    @ApiImplicitParams({
            @ApiImplicitParam(name = "ralId",value = "积分id",required = true,paramType = "query")
    })
    public Result select(@RequestParam(required = true)Long ralId){
        tbIntegralService.select(ralId);
        return Result.buildResult(ResultEnum.SUCCESS);
    }
}

